package com.weixing.mall.provider.model.excel;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.weixing.mall.base.constant.GlobalConstant;
import com.weixing.mall.provider.api.model.enums.OrderTypeEnum;
import com.weixing.mall.provider.model.enums.DefectiveProductEunm;
import com.weixing.mall.provider.model.enums.DefectiveProductReasonEunm;
import lombok.Data;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

/**
 * @Author wx
 * @Date 2019/10/25 14:16
 * @Version 1.0
 */
@Data
@ContentRowHeight(100)
public class DefectiveProductED {
    @ExcelProperty("序号")
    @ExcelIgnore
    private Long id;
    @ExcelProperty("商品图片")
    @ExcelIgnore
    private String productImg;
    @ExcelProperty("商品图片")
    private URL imgUrl;
    @ExcelProperty("货号")
    private String goodsSn;
    @ExcelProperty("商品编号")
    @ExcelIgnore
    private String productSn;
    @ExcelProperty("商品名称")
    private String productName;
    @ExcelProperty("颜色尺码")
    @ExcelIgnore
    private String spec;
    @ExcelProperty("颜色")
    private String color;
    @ExcelProperty("尺码")
    private String size;
    @ExcelProperty("入库时间")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    private Date createdTime;
    @ExcelProperty("出库时间")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    private Date outDepotTime;
    @ExcelProperty("客户名称")
    private String contactUser;
    @ExcelProperty("手机号")
    private String contactPhone;
    @ExcelProperty("所属客服")
    private String customerName;
    @ExcelProperty("所属代理")
    private String agentName;
    @ExcelProperty("状态")
    @ExcelIgnore
    private DefectiveProductEunm productStatus;
    @ExcelProperty("状态")
    private String defectiveProductDesp;
    @ExcelProperty("订单类型")
    @ExcelIgnore
    private OrderTypeEnum orderType;
    @ExcelProperty("订单类型")
    private String orderTypeDesp;
    @ExcelProperty("活动名称")
    private String actName;
    @ExcelProperty("备注")
    private String remark;

    public void setProductImg(String productImg){
        this.productImg = productImg;
        try {
            if (StrUtil.isNotEmpty(productImg)){
                this.imgUrl =new URL(GlobalConstant.IMG_PATH_URL +productImg+GlobalConstant.IMG_PATH_URL_SUFFIX);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    public void setOrderType(OrderTypeEnum orderType){
        this.orderType = orderType;
        if(orderType != null){
            this.orderTypeDesp = orderType.getDesp();
        }
    }

    public void setProductStatus(DefectiveProductEunm productStatus){
        this.productStatus = productStatus;
        if(productStatus != null){
            this.defectiveProductDesp = productStatus.getDesp();
        }
    }

}
